import request from "@/utils/request";
import i18n from "@/lang";
import modal from "@/plugins/modal.js";

const device = import.meta.env.VITE_APP_ENV === "production" ? "" : "/device"

export function download(url) {
	return request({
		url: `${device}/config/${url}`,
		headers: {
			isToken: false,
			//   'Content-Type': 'application/x-www-form-urlencoded',
			responseType: "blod",
		},
		method: "get",
	})
		.then((res) => {
			return { name: url, res };
		})
		.catch((e) => {
			modal.msgError(`[${url}]${i18n.global.t("Download failed")}`);
		});
}
export const uploadUrl = `${device}/upload.php`;
export const upcfgUrl = `${device}/upcfg.php`;
